package com.pdstudio.carrecom.ui.fragment.account;

import com.pdstudio.carrecom.R;
import com.pdstudio.carrecom.app.UIHelper;
import com.pdstudio.carrecom.tools.StringUtils;
import com.pdstudio.carrecom.ui.activity.account.ActivityGoRegister;

import android.app.Activity;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;

public class FragmentRegisterS3 extends Fragment {

	private View _view;
	private Activity _context;
	private Button _nextStep;
	private EditText mUserName, mPass, mPassAg;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		_view = inflater.inflate(R.layout.fragment_account_register_s3,
				container, false);
		_context = getActivity();
		initialView();
		return _view;
	}

	public void initialView() {
		mUserName = (EditText) _view.findViewById(R.id.et_rg_username);
		mPass = (EditText) _view.findViewById(R.id.et_rg_pass);
		mPassAg = (EditText) _view.findViewById(R.id.et_rg_passag);
		_nextStep = (Button) _view.findViewById(R.id.btn_rg_nextstep);
		_nextStep.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub

				if (StringUtils.isEmpty(mUserName.getEditableText().toString())
						|| StringUtils.isEmpty(mPass.getText().toString())) {
					UIHelper.ToastMessage(_context, "用户名或者密码不能为空");
				} else {
					if (!mPass.getText().toString()
							.equals(mPassAg.getText().toString())) {
						UIHelper.ToastMessage(_context, "两次输入的密码不一致");
					} else {
						// 记录用户的电话号码跟车型
						ActivityGoRegister agr = (ActivityGoRegister) _context;
						agr.mUserName = mUserName.getText().toString();
						agr.mPass = mPass.getText().toString();
						agr.openFragment(new FragmentRegisterS4());
					}
				}

			}
		});
	}

}
